<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<link rel="stylesheet" href="assets/layui/css/layui.css">
<body style="margin: 50px">
<div class="layui-input-inline">

    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" id="rangetimes" name="phone" lay-verify="required|phone" autocomplete="off"
                       class="layui-input" placeholder="          起始 - 截止">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" id="number" name="number" lay-verify="number" autocomplete="off" class="layui-input"
                       placeholder="学号">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" id="uname" name="username" lay-verify="username" autocomplete="off"
                       class="layui-input"
                       placeholder="姓名">
            </div>
        </div>

        <div class="layui-inline">
            <div class="layui-form" style="margin-bottom: 12px">
                <form class="layui-form" action="" lay-filter="example">
                    <input type="checkbox" name="tempup" title="≥37.5" lay-skin="primary" >
                    <div class="layui-unselect layui-form-checkbox layui-form-checked" lay-skin="primary" >
                        <span>≥37.5</span><i class="layui-icon layui-icon-ok"></i></div>
                    <input type="checkbox" name="today" title="今日" lay-skin="primary" >
                    <div class="layui-unselect layui-form-checkbox" lay-skin="primary" checked="" ><span>今日</span><i
                            class="layui-icon layui-icon-ok"></i></div>
                </form>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <button type="button" class="layui-btn layui-btn-normal" id="LAY-component-form-getval">提交</button>
                <button type="button" class="layui-btn layui-btn-normal" id="LAY-component-form-clear">清空</button>
            </div>
        </div>
    </div>
</div>
<table class="layui-hide" id="test" lay-filter="test"></table>
</body>
<script type="text/javascript" src="assets/layui/layui.js"></script>
<script type="text/javascript" src="assets/jquery.min.js"></script>
<script>
    var table
    layui.use(['form', 'table', 'layer', 'laydate'], function () {
        var form = layui.form
        table = layui.table;
        laydate = layui.laydate;
        laydate.render({
            elem: '#rangetimes'
            , type: 'datetime'
            , range: true
            , done: function (value, date, endDate) {

                var ftime = '';
                var ltime = '';
                if (value != null && value != '') {
                    ftime = value.split(" - ")[0]
                    ltime = value.split(" - ")[1]
                }
                showtable(ftime, ltime)
            }
        });


        // 获取数据
        showtable()


        function showtable(ftime, ltime, number, uname, istoday, tempup) {

            table.render({
                elem: '#test'
                , url: '/api/v1/temp/showstudenttemp'
                , toolbar: true
                , title: '学生体温信息表'
                , totalRow: true
                , cols: [[
                    {field: 'number', title: 'ID', fixed: 'left', unresize: true, sort: true}
                    , {field: 'name', title: '姓名', edit: 'text'}
                    , {field: 'temp', title: '体温', edit: 'text', sort: true}
                    , {field: 'time', title: '时间', edit: 'text', sort: true}

                ]]
                , page: true
                , response: {
                    statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                }
                , where: {
                    "uname": uname,
                    "number": number,
                    "tempup": tempup,
                    "ftime": ftime,
                    "istoday": istoday,
                    "ltime": ltime,
                }
                /* ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
                     return {
                         "code": res.status, //解析接口状态
                         "msg": res.message, //解析提示文本
                         "count": res.total, //解析数据长度
                         "data": res.rows.item //解析数据列表
                     };
                 }*/
            });
        }

        layui.$('#LAY-component-form-getval').on('click', function () {
            var data = form.val('example');
            var number = $("#number").val();
            var uname = $("#uname").val();
            var rangetimes = $("#rangetimes").val();
            var ftime = '';
            var ltime = '';
            if (rangetimes != null && rangetimes != '') {
                ftime = rangetimes.split(" - ")[0]
                ltime = rangetimes.split(" - ")[1]
            }
            var istoday = data.today;
            var tempup = data.tempup;
            showtable(ftime, ltime, number, uname, istoday, tempup)
        });
        layui.$('#LAY-component-form-clear').on('click', function () {
            $("#number").val("");
            $("#uname").val("");
            $("#rangetimes").val("");
            form.val('example', {
                "today": false, //复选框选中状态
                "tempup": false //复选框选中状态
            });
            showtable()

        });
    });

</script>
</html>